package com.budwk.app.sqfwV2.enums.centuryCitySafe;

import com.budwk.app.sqfwV2.dto.dto.centuryCity.SafeCheckTaskParamDataDTO;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * 大型企业安全检查表问题数组
 */
@Getter
public enum LargeSafeProblemsEnum {

    ONE("1","enterpriseSecurityTraining", "是", "企业主要负责人是否组织专题安全教育培训", "企业主要负责人未组织专题安全教育培训"),
    TWO("2","enterpriseAccidentProblem", "是", "企业是否开展重大事故隐患判定标准、检查指引等配套文件宣贯、解读", "企业未开展重大事故隐患判定标准、检查指引等配套文件宣贯、解读"),
    THREE("3","enterpriseSecuritySkills", "是", "企业是否开展从业人员安全技能培训", "企业未开展从业人员安全技能培训"),
    FORE("4","enterpriseInspection", "是", "企业主要负责人是否按要求带队检查", "企业主要负责人未按要求带队检查"),
    FIVE("5","enterpriseLaborDispatch", "是", "企业是否开展外包外租、劳务派遣、灵活用工", ""),
    SIX("6","workWithoutALicense", "否", " 是否查处电焊等特种作业岗位人员无证上岗作业", "该企业电焊等特种作业岗位人员无证上岗作业"),
    SEVEN("7","buildRescueTeam", "是", "生产经营单位是否建设安全生产应急救援队伍", "该企业生产经营单位未建设安全生产应急救援队伍");

    private final String riskCode;

    private final String fields;

    private final String defaultValue;

    private final String riskDesc;

    private final String harardDesc;

    LargeSafeProblemsEnum(String riskCode, String fields, String defaultValue, String riskDesc, String harardDesc) {
        this.riskCode = riskCode;
        this.fields = fields;
        this.defaultValue = defaultValue;
        this.riskDesc = riskDesc;
        this.harardDesc = harardDesc;
    }

    public static LargeSafeProblemsEnum getEnumByFields(String fields) {
        Optional<LargeSafeProblemsEnum> optional = Arrays.stream(values()).filter(e -> e.getFields().equals(fields)).findFirst();
        return optional.orElse(null);
    }

    /**
     * 获取问题的默认值
     * @return
     */
    public static List<SafeCheckTaskParamDataDTO> getDefaultValues() {
        List<SafeCheckTaskParamDataDTO> list = new ArrayList<>();
        for (LargeSafeProblemsEnum e : values()) {
            SafeCheckTaskParamDataDTO safe = new SafeCheckTaskParamDataDTO();
            safe.setKey(e.getDefaultValue()).setFields(e.getFields()).setRiskCode(e.getRiskCode()).setRiskDesc(e.getRiskDesc());
            list.add(safe);
        }
        return list;
    }
}
